package com.tencent.sr.iris.basic.saas.restapi.activity;

import com.tencent.sr.iris.activity.interfaces.request.IrisPaginationRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityMonthLimitAddRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityUidLimitAddRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityUidLimitPageRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityUidLimitUpdateRequest;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityMonthLimitResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityUidLimitResponse;
import com.tencent.sr.iris.basic.saas.service.activity.ActivityConfigService;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@Api("活动配置")
@RequestMapping("/iris/basic/saas/v1/activity/config")
public class ActivityConfigController {

    @Resource
    private ActivityConfigService activityConfigService;

    @PostMapping("monthLimitConfigPage")
    @ApiOperation(value = "查询月份限额列表", httpMethod = "POST")
    public HttpResult<PaginationResponse<ActivityMonthLimitResponse>> monthLimitConfigPage(
            @Validated @RequestBody PaginationRequest request) {
        PaginationResponse<ActivityMonthLimitResponse> page = activityConfigService.monthLimitConfigPage(request);
        return HttpResult.succ(page);
    }

    @PostMapping("uidLimitConfigPage")
    @ApiOperation(value = "查询uid限额列表", httpMethod = "POST")
    public HttpResult<PaginationResponse<ActivityUidLimitResponse>> uidLimitConfigPage(
            @Validated @RequestBody IrisPaginationRequest<ActivityUidLimitPageRequest> request) {
        PaginationResponse<ActivityUidLimitResponse> page = activityConfigService.uidLimitConfigPage(request);
        return HttpResult.succ(page);
    }

    @PostMapping("addCurrentMonthLimit")
    @ApiOperation(value = "新增当月配置", httpMethod = "POST")
    public HttpResult<Boolean> addCurrentMonthLimit(
            @Validated @RequestBody ActivityMonthLimitAddRequest request) {
        Boolean page = activityConfigService.addCurrentMonthLimit(request);
        return HttpResult.succ(page);
    }

    @PostMapping("addUidLimit")
    @ApiOperation(value = "新增uid配置", httpMethod = "POST")
    public HttpResult<Boolean> addUidLimit(
            @Validated @RequestBody ActivityUidLimitAddRequest request) {
        Boolean page = activityConfigService.addUidLimit(request);
        return HttpResult.succ(page);
    }

    @PostMapping("updateUidLimit")
    @ApiOperation(value = "更新uid配置", httpMethod = "POST")
    public HttpResult<Boolean> updateUidLimit(
            @Validated @RequestBody ActivityUidLimitUpdateRequest request) {
        Boolean page = activityConfigService.updateUidLimit(request);
        return HttpResult.succ(page);
    }
}
